class_name 恶灵Operation extends Node

var operationManager:OperationManager
var big:Big

func init(om:OperationManager):
	self.operationManager = om
	return self

# 灵狩
func preparation_恶灵_attack():
	operationManager.arr_listeningPoints.clear()
	var point = operationManager.selectedPoint
	var arrAroundPoints = GameUtils.getArrPointsAround1And2(point)
	for p in arrAroundPoints:
		if p.is_view:
			if p.real_terrain == Terrain.jing:
				continue
			if p.small != null:
				continue
			if p.big != null:		#有大子
				if p.big.player.is_me:	#是自己的
					continue
		operationManager.arr_listeningPoints.append(p)
	GameUtils.neatAnimation()
	big = point.big
	big.detailHide()

# 附身
func preparation_恶灵_possess():
	operationManager.arr_listeningPoints.clear()
	var point = operationManager.selectedPoint
	var arrAroundPoints = GameUtils.getArrPointsAround1And2(point)
	for p in arrAroundPoints:
		if p.is_view:
			if p.real_terrain == Terrain.jing:
				continue
			if p.small != null:
				continue
			if p.big != null:		#有大子
				if p.big.player.is_me:	#是自己的
					continue
				if p.big.evolution != "未转型":
					continue
				if !p.big.arr_states.has(BigStateType.HIDE) && !p.big.arr_states.has(BigStateType.FEAR):
					continue
		operationManager.arr_listeningPoints.append(p)
	GameUtils.neatAnimation()
	big = point.big
	big.detailHide()

func 恶灵_attack(point:Point):
	WebSocketManager.sendObj(true,"恶灵_attack",{"start":big.point.id,"end":point.id})
	operationManager.cancel()

func 恶灵_possess(point:Point):
	WebSocketManager.sendObj(true,"恶灵_possess",{"start":big.point.id,"end":point.id})
	operationManager.cancel()
